package rohyunji.swing.jdbc;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Font;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.FontUIResource;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JSeparator;
import javax.swing.JToolBar;
import javax.swing.JButton;
import javax.swing.JTabbedPane;
import javax.swing.UIManager;

import java.awt.Dimension;
import java.util.Enumeration;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.JSlider;
import javax.swing.BoxLayout;
import javax.swing.JScrollBar;
import javax.swing.JTable;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;

public class J26_SungJUkMainFrame extends JFrame {

	private JPanel contentPane;
	private static J26_SungJUkMainFrame frame = null;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					frame = new J26_SungJUkMainFrame();
					frame.setVisible(true);
					frame.setLocationRelativeTo(null);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public J26_SungJUkMainFrame() {

		setUIFont(new FontUIResource("맑은고딕", Font.BOLD, 14));
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 800, 600);

		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);

		JMenu mnFile = new JMenu("파일(F)");
		menuBar.add(mnFile);

		JMenuItem miNew = new JMenuItem("새 성적(N)");
		miNew.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			new J26_SungJukNewDatabase(frame);
		}
		});
		mnFile.add(miNew);

		JSeparator separator = new JSeparator();
		mnFile.add(separator);

		JMenuItem miExit = new JMenuItem("종료(X)");
		miExit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		mnFile.add(miExit);

		JMenu mnView = new JMenu("보기 (V)");
		menuBar.add(mnView);

		JMenuItem mntmNewMenuItem_2 = new JMenuItem("전체성적보기(L)");
		mntmNewMenuItem_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				new J26_SungJukShowList(frame);
			}
		});

		mnView.add(mntmNewMenuItem_2);

		JMenu mnHelp = new JMenu("도움말(H)");
		menuBar.add(mnHelp);

		JMenuItem miHelp = new JMenuItem("도움말 항목(H)");
		mnHelp.add(miHelp);

		JSeparator separator_1 = new JSeparator();
		mnHelp.add(separator_1);

		JMenuItem miabout = new JMenuItem("프로그램 정보(A)");
		miabout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				new J26_SungJukAboutDialog(frame);
			}
		});
		mnHelp.add(miabout);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);

		JPanel panel = new JPanel();
		contentPane.add(panel, BorderLayout.NORTH);

		JPanel panel_1 = new JPanel();
		contentPane.add(panel_1, BorderLayout.EAST);

		JPanel panel_2 = new JPanel();
		contentPane.add(panel_2, BorderLayout.SOUTH);

		JPanel panel_3 = new JPanel();
		contentPane.add(panel_3, BorderLayout.WEST);

		JPanel panel_4 = new JPanel();
		contentPane.add(panel_4, BorderLayout.CENTER);
		panel_4.setLayout(new BorderLayout(0, 0));

		JLabel lblNewLabel = new JLabel("");
		lblNewLabel.setIcon(new ImageIcon(J26_SungJUkMainFrame.class
				.getResource("/images/toolbar/이미지 3.jpg")));
		panel_4.add(lblNewLabel);
	}

	private void setUIFont(FontUIResource fuir) {
		Enumeration<Object> keys = UIManager.getDefaults().keys();
		// 모든 스윙 컴퍼넌트 이름(label,button 등등) 을 keys에 저장
		while (keys.hasMoreElements()) {
			Object key = keys.nextElement();// 속성을 갖고옴

			Object val = UIManager.get(key);
			if (val != null && val instanceof FontUIResource)
				// 속성이 폰트와 관련있으면 사용자가 지정한 글꼴로 변경
				UIManager.put(key, fuir);

		}
	}

}
